

<?php
    
    require "config.php";
    require "course_availability.php";
    
    $course_selected = strtolower( $_POST['coursename1']);
    
    echo "List of  training links for the course  ".$course_selected ."</br>";
    $available = course_availability($course_selected);
    if ( $available == 0){
        echo "Invalid course"."</br>";
    }
    
    else {
        //echo "valid course";
       // retrieveFromDatabase($course_selected);
    
    
    
    //function retrieveFromDatabase($course_selected){
        
        $con = mysql_connect($db_host,$db_user ,$db_pass);
        
        if (!$con){
            die('Could not connect: ' . mysql_error());
        }
        
        mysql_select_db($db_name, $con);
        
        $sql_retrieve = "SELECT * from course where course_name = '".$course_selected."' ;";
        $result = mysql_query( $sql_retrieve);
        
        while($row = mysql_fetch_array($result))
        {
            $link = $row['course_link'];
            echo '<a href="' . $link. '"> ' .$link.' </a>'."</br>";
            
        }
        mysql_close($con);
        
    }
        
        
    
    
    
            
?>



